/* vim: set ts=2 sw=2 sts=2 et: */

$(function () {
if ( $(window).width() > 680) {
  $(ajax.messages).bind(
    'productAdded',
    function(e, data) {

      $('.ui-dialog-content').dialog('close');

      var dialog = $(data.content).dialog({

        dialogClass: "product-added",
        modal: true,
        title: data.title,
        width: 550,
        zIndex: 10000,
        resizable: false,
        //position: ["center", 150],
        position: ["center", "center"],

        dragStart: function (event, ui) {
          $('.product-added').css('opacity', '0.7');
        },

        dragStop: function (event, ui) {
          $('.product-added').css('opacity', '1.0');
        },

        open: function () {
          $(".product-added .view-cart").button();
          $(".product-added .continue-shopping").button().click(function () {
            dialog.dialog('close');
            return false;
          });
          $(".product-added .proceed-to-checkout").button().click(function () {
            dialog.dialog('close');
          });
          $('.ui-widget-overlay').click(function () {
            dialog.dialog('close');
          });
        }

      });

      $('.ui-dialog a').blur();

      ajax.widgets.products();
    }
  );
}
});
